# -*- coding: utf-8 -*-
"""
date: Fri Dec 14 14:53:56 2018
python: Anaconda 3.6.5
author: kanade
email: kanade@blisst.cn
"""
import numpy as np
import matplotlib.pyplot as mp


# 生成数据
n = 1000
x, y = np.meshgrid(np.linspace(-3, 3, n),
                   np.linspace(-3, 3, n))
# 以下代码注释代码和上一句效果一样
#x = np.tile(np.linspace(-3, 3, n),reps=(n, 1))
#y = np.tile(np.linspace(-3, 3, n),reps=(n, 1)).T

# 随便挑了个空间函数
z = (1 - x / 2 + x ** 5 + y ** 3) * np.exp(
    -x ** 2 - y ** 2)

mp.figure('Contour', facecolor='lightgray') # 创建图形窗口

mp.subplot(321)
mp.title('Contour1', fontsize=14)
mp.xticks(())
mp.yticks(())
# 绘制等高线图
cntr = mp.contour(x, y, z, 8, colors='springgreen',
                  linewidths=0.5)
mp.clabel(cntr, inline_spacing=1, fmt='%.1f',
         fontsize=6)

mp.subplot(322)
mp.title('Contour2', fontsize=14)
mp.xticks(())
mp.yticks(())
mp.contourf(x, y, z, 8, cmap='Greys')

mp.subplot(323)
mp.title('Contour3', fontsize=14)
mp.xticks(())
mp.yticks(())
cntr = mp.contour(x, y, z, 8, colors='black',
                  linewidths=0.5)
mp.contourf(x, y, z, 8, cmap='jet')
mp.clabel(cntr, inline_spacing=1, fmt='%.1f',
         fontsize=6)

mp.subplot(324)
mp.title('Contour3', fontsize=14)
mp.xticks(())
mp.yticks(())
cntr = mp.contour(x, y, z, 8, colors='black',
                  linewidths=0.5)
mp.contourf(x, y, z, 8, cmap='cool')
mp.clabel(cntr, inline_spacing=1, fmt='%.1f',
         fontsize=6)

mp.subplot(325)
mp.title('Contour2', fontsize=14)
mp.xticks(())
mp.yticks(())
mp.contourf(x, y, z, 8, cmap='prism')

mp.subplot(326)
mp.title('Contour2', fontsize=14)
mp.xticks(())
mp.yticks(())
mp.contourf(x, y, z, 8, cmap='pink')


mp.tight_layout()
mp.show()
